package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 字典表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "Dict对象", description = "字典表")
public class Dict implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("字典id 自增长")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("字典名字")
    private String name;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    public static DictBuilder builder() {
        return new DictBuilder();
    }

    public static final class DictBuilder {
        private Integer id;
        private String name;
        private String remark;
        private Boolean del;
        private LocalDateTime createTime;

        private DictBuilder() {
        }


        public DictBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public DictBuilder name(String name) {
            this.name = name;
            return this;
        }

        public DictBuilder remark(String remark) {
            this.remark = remark;
            return this;
        }

        public DictBuilder del(Boolean del) {
            this.del = del;
            return this;
        }

        public DictBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public Dict build() {
            Dict dict = new Dict();
            dict.setId(id);
            dict.setName(name);
            dict.setRemark(remark);
            dict.setDel(del);
            dict.setCreateTime(createTime);
            return dict;
        }
    }
}
